public class ReactorNettyTcpClient<P> extends java.lang.Object implements TcpOperations<P>
TcpOperations
.Modifier and Type | Class and Description |
---|---|
private class |
ReactorNettyTcpClient.ReactorNettyHandler |
private static class |
ReactorNettyTcpClient.StompMessageDecoder<P> |
Modifier and Type | Field and Description |
---|---|
private ChannelGroup |
channelGroup |
private ReactorNettyCodec<P> |
codec |
private LoopResources |
loopResources |
private PoolResources |
poolResources |
private static int |
PUBLISH_ON_BUFFER_SIZE |
private Scheduler |
scheduler |
private boolean |
stopping |
private TcpClient |
tcpClient |
Constructor and Description |
---|
ReactorNettyTcpClient(java.util.function.Consumer<<any>> optionsConsumer,
ReactorNettyCodec<P> codec)
Constructor with a
ClientOptions.Builder that can be used to
customize Reactor Netty client options. |
ReactorNettyTcpClient(java.lang.String host,
int port,
ReactorNettyCodec<P> codec)
Simple constructor with a host and a port.
|
ReactorNettyTcpClient(TcpClient tcpClient,
ReactorNettyCodec<P> codec)
Constructor with an externally created
TcpClient instance whose
lifecycle is expected to be managed externally. |
Modifier and Type | Method and Description |
---|---|
ListenableFuture<java.lang.Void> |
connect(TcpConnectionHandler<P> handler)
Open a new connection.
|
ListenableFuture<java.lang.Void> |
connect(TcpConnectionHandler<P> handler,
ReconnectStrategy strategy)
Open a new connection and a strategy for reconnecting if the connection fails.
|
private ListenableFuture<java.lang.Void> |
handleShuttingDownConnectFailure(TcpConnectionHandler<P> handler) |
private <T> java.util.function.Function<<any>,<any>> |
reconnectFunction(ReconnectStrategy reconnectStrategy) |
ListenableFuture<java.lang.Void> |
shutdown()
Shut down and close any open connections.
|
private <any> |
stopScheduler() |
private <T> java.util.function.Consumer<T> |
updateConnectMono(<any> connectMono) |
private static final int PUBLISH_ON_BUFFER_SIZE
private final TcpClient tcpClient
private final ReactorNettyCodec<P> codec
@Nullable private final ChannelGroup channelGroup
@Nullable private LoopResources loopResources
@Nullable private PoolResources poolResources
private final Scheduler scheduler
private volatile boolean stopping
public ReactorNettyTcpClient(java.lang.String host, int port, ReactorNettyCodec<P> codec)
host
- the host to connect toport
- the port to connect tocodec
- the code to useStompReactorNettyCodec
public ReactorNettyTcpClient(java.util.function.Consumer<<any>> optionsConsumer, ReactorNettyCodec<P> codec)
ClientOptions.Builder
that can be used to
customize Reactor Netty client options.
Note: this constructor manages the lifecycle of the
TcpClient
and its underlying resources. Please do not customize
any of the following options:
ChannelGroup
,
LoopResources
, and
PoolResources
.
You may set the disablePool
option if you simply want to turn off pooling.
For full control over the initialization and lifecycle of the TcpClient,
see ReactorNettyTcpClient(TcpClient, ReactorNettyCodec)
.
optionsConsumer
- consumer to customize client optionscodec
- the code to useStompReactorNettyCodec
public ReactorNettyTcpClient(TcpClient tcpClient, ReactorNettyCodec<P> codec)
TcpClient
instance whose
lifecycle is expected to be managed externally.tcpClient
- the TcpClient instance to usecodec
- the code to useStompReactorNettyCodec
public ListenableFuture<java.lang.Void> connect(TcpConnectionHandler<P> handler)
TcpOperations
connect
in interface TcpOperations<P>
handler
- a handler to manage the connectionpublic ListenableFuture<java.lang.Void> connect(TcpConnectionHandler<P> handler, ReconnectStrategy strategy)
TcpOperations
connect
in interface TcpOperations<P>
handler
- a handler to manage the connectionstrategy
- a strategy for reconnectingprivate ListenableFuture<java.lang.Void> handleShuttingDownConnectFailure(TcpConnectionHandler<P> handler)
private <T> java.util.function.Consumer<T> updateConnectMono(<any> connectMono)
private <T> java.util.function.Function<<any>,<any>> reconnectFunction(ReconnectStrategy reconnectStrategy)
public ListenableFuture<java.lang.Void> shutdown()
TcpOperations
shutdown
in interface TcpOperations<P>
private <any> stopScheduler()